#include <iostream>
#include <malloc.h>
using namespace std;

typedef struct TREE_NODE
{
    int data;
    TREE_NODE* next;
} Tree_Node;

int main(){
    int arr[]  = {1,2,3,4,5,6};
    Tree_Node *head = 0;
    Tree_Node * curr = 0;
    for(int a : arr){
        if(curr==0){
            curr = (Tree_Node*)malloc(sizeof(Tree_Node));
            curr->data = a;
            head = curr;
        }else{
            Tree_Node *p = (Tree_Node *)malloc(sizeof(Tree_Node));
            cout<<p<<endl;
            curr->next = p;
            curr = p;
            curr->data = a;
            // curr = (curr->next = (Tree_Node *)malloc(sizeof(Tree_Node)));
            // curr->data = a;
        }
    }
    curr->next = 0;
    while (head!=0)
    {
        cout<<"---"<<head->data<<endl;
        head = head->next;
    }
    
    return 0;
}